﻿#pragma once
#include <string>
#include <vector>
#include <json/json.h>

namespace au
{
    typedef enum
    {
        date1_g_date2 = 57,
        date1_eql_date2 = 58,
        date1_less_date2 = 59
    } DATE_COMPARE;

    typedef enum   
    {
        UNDOWNLOAD_STATE = 0,  // 未下载
        DOWNLOADING_STATE,       // 正在下载
        COMPLETED_STATE,         // 下载完成
        ERROR_STATE         // 下载失败
    }ModelInitStatus;

    enum CFGFileUpdateFlag {
        CFGFileNoUpdate,
        CFGFileUpdateCore,
        CFGFileUpdateOther,
    };

    typedef struct{
        std::string filename; //模型文件名字
        std::vector<unsigned char> filedata; //模型文件
    }ModelFile;

    struct AuthCenterServerInfo{
        AuthCenterServerInfo(){}
        AuthCenterServerInfo(const AuthCenterServerInfo& aus){
        *this = operator=(aus);
        }
        AuthCenterServerInfo& operator=(const AuthCenterServerInfo& aus) {
            if (this == &aus) { return *this; }
            this->authCenter_ip_port = aus.authCenter_ip_port;
            this->Update_heart = aus.Update_heart;
            this->GetModelInfoURl = aus.GetModelInfoURl;
            this->GetAlgoEventURL = aus.GetAlgoEventURL;
            this->RegisterDeviceURL = aus.RegisterDeviceURL;
            return *this;
        }
        std::string authCenter_ip_port;
        std::string Update_heart;
        std::string GetModelInfoURl;
        std::string GetAlgoEventURL;
        std::string RegisterDeviceURL;
    };

    struct ModelInfo{
        ModelInfo(){}
        ModelInfo(const ModelInfo& mbi){
        *this = operator=(mbi);
        }
        ModelInfo& operator=(const ModelInfo& mbi) {
            if (this == &mbi) { return *this; }
            this->model_id = mbi.model_id;
            this->auth_expire_date= mbi.auth_expire_date;
            this->max_continue_infer_times = mbi.max_continue_infer_times;
            this->max_device_count = mbi.max_device_count;
            this->model_filename= mbi.model_filename;
            this->model_version = mbi.model_version;
            this->auth_classes = mbi.auth_classes;
            this->encrypt_string = mbi.encrypt_string;
            return *this;
        }
            std::string model_id;
            std::string auth_expire_date;
            int max_continue_infer_times;
            int max_device_count;

            std::string model_filename;
            std::string model_version;
            std::string encrypt_string;

            std::vector<std::string> auth_classes;

            // std::vector<std::string> model_filename;
            // std::vector<std::string> model_version;
            // std::vector<std::string> encrypt_string;
    };

    
    // struct Models_info{
    //     Models_info(){}
    //     Models_info(const Models_info& mi){
    //     *this = operator=(mi);
    //     }
    //     Models_info& operator=(const Models_info& mi) {
    //         if (this == &mi) { return *this; }
    //         this->model_id = mi.model_id;
    //         this->auth_classes = mi.auth_classes;
    //         return *this;
    //     }
    //         std::string model_id;
    //         std::vector<std::string> auth_classes;
    // };

    struct authModelLabel{
    authModelLabel(){}
    authModelLabel(const authModelLabel& mi){
        *this = operator=(mi);
    }
    authModelLabel& operator=(const authModelLabel& mi) {
        if (this == &mi) { return *this; }
        this->model_id = mi.model_id;
        this->auth_labeles = mi.auth_labeles;
        return *this;
    }
    std::string model_id;
    std::vector<std::string> auth_labeles;
    };

    struct AffectionInfo {
    AffectionInfo():alg_instance_count(0),video_count(0){}
    AffectionInfo(const AffectionInfo& ci) {
        *this = operator=(ci);
    }
    AffectionInfo& operator=(const AffectionInfo& ai) {
        if (this == &ai) { return *this; }
        this->alg_instance_count = ai.alg_instance_count;
        this->video_count = ai.video_count;
        return *this;
    }
    int alg_instance_count; //当前设备管理的实例数
    int video_count; //当前设备管理的视频路数
    };

    struct AffectionMsgBase {
    AffectionMsgBase():alg_instance_is_ok(1),video_is_ok(1){}
    AffectionMsgBase(const AffectionMsgBase& ci) {
        *this = operator=(ci);
    }
    AffectionMsgBase& operator=(const AffectionMsgBase& am) {
        if (this == &am) { return *this; }
        this->stop_all = am.stop_all;
        this->alg_instance_is_ok = am.alg_instance_is_ok;
        this->video_is_ok = am.video_is_ok;
        return *this;
    }
        int stop_all; //是否停止所有，表示日期过期或者其他原因，需停止所有通道和事例
        int alg_instance_is_ok; //判断事件实例是否通过验证
        int video_is_ok; //判断设备视频是否通过验证
    };

    struct AffectionMsg {
    AffectionMsg():alg_instance_is_ok(1),video_is_ok(1){}
    AffectionMsg(const AffectionMsg& ci) {
        *this = operator=(ci);
    }
    AffectionMsg& operator=(const AffectionMsg& am) {
        if (this == &am) { return *this; }
        this->auth_expire_date = am.auth_expire_date;
        this->alg_instance_is_ok = am.alg_instance_is_ok;
        this->video_is_ok = am.video_is_ok;
        return *this;
    }
        std::string auth_expire_date; //当前事件的过期时间
        int alg_instance_is_ok; //判断事件实例是否通过验证
        int video_is_ok; //判断设备视频是否通过验证
    };

    struct InferInfo {
    InferInfo():device_count(0),continue_infer_times(0){}
    InferInfo(const InferInfo& it) {
        *this = operator=(it);
    }
    InferInfo& operator=(const InferInfo& it) {
        if (this == &it) { return *this; }
        this->device_count = it.device_count;
        this->continue_infer_times = it.continue_infer_times;
        return *this;
    }

        int device_count; //推理线程数量
        int continue_infer_times; //推理次数
    };

    
    typedef struct AuConfigInfo
    {
        AuConfigInfo(){}
        AuConfigInfo(const AuConfigInfo& cfm){
            *this = operator=(cfm);
        }
        AuConfigInfo& operator=(const AuConfigInfo& cfm) {
            if (this == &cfm) { return *this; }
            this->device_code = cfm.device_code;
            this->authCenter_server_info = cfm.authCenter_server_info;
            this->mac_address= cfm.mac_address;
            this->cpu_address= cfm.cpu_address;
            this->models_dir= cfm.models_dir;
            this->models= cfm.models;
            this->infer_times_map= cfm.infer_times_map;
            return *this;
        }
        std::string device_code; //本设备的device_code
        AuthCenterServerInfo authCenter_server_info;

        std::string mac_address;
        std::string cpu_address;
        std::string models_dir;

        std::map<std::string,InferInfo> infer_times_map; //推理次数进行限定  //每一个id对应一个推理次数和推理的最大线程数

        std::vector<ModelInfo> models;

    } AuConfigInfo_;

}